import { useEffect, useState } from "react";

export function useWindowSize() {
	const [windowSize, setWindowSize] = useState({
		width: document.documentElement.clientWidth,
		height: document.documentElement.clientHeight
	});

	const fn = () => {
		setWindowSize({
			width: document.documentElement.clientWidth,
			height: document.documentElement.clientHeight
		});
	};

	useEffect(() => {
		window.addEventListener("resize", fn);

		return () => {
			window.removeEventListener("resize", fn);
		};
	}, []);

	return [windowSize];
}
